package com.acme.bankapp.service.bank;

import com.acme.bankapp.domain.bank.Email;

/**
 * Created by Student on 21.11.2014.
 */
public class MailsThread implements Runnable {
    private Queue queue;

    public MailsThread(Queue queue) {
        this.queue = queue;
    }

    @Override
    public void run() {

        Email email = null;
        while (!Thread.interrupted()) {
            try {
                email = queue.remove();
            } catch (InterruptedException e) {
                System.out.println("MailsThread was interrupted");
                return;
            }
            if (email != null) {
                System.out.println("Email sended to " + email.getEmailAddress() + "@db.com");
            }
        }

        return;
    }

}

